package com.yanqu.road.server.cmd.activity.guagifts;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.GuaGiftsProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.guagifts.GuaGiftsModule;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameProtocol;

@Cmd(code = GameProtocol.S_GUAGIFTS_GET_RELATION_LIST, desc = "孤寡献礼获得关系列表")
public class GuaGiftsGetRelationListCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {

        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        GuaGiftsProto.GuaGiftsRelationListReqMsg reqMsg = GuaGiftsProto.GuaGiftsRelationListReqMsg.parseFrom(packet.getBytes());
        ret = player.getModule(GuaGiftsModule.class).getRelationList(reqMsg.getGiftType(), reqMsg.getTapType());

    }

    @Override
    public void sendData(GamePlayer player) {
        if (ret != 0) {
            player.sendPacket(ClientProtocol.U_GUAGIFTS_GET_RELATION_LIST, GuaGiftsProto.GuaGiftsRelationListRespMsg.newBuilder().setRet(ret));
        }
    }
}
